package com.endava.nio_io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class Nio_SimpleWriting {
	public static void main(String[] args) throws IOException {
		FileOutputStream fos=new FileOutputStream("filemy.txt");
		FileChannel fc=fos.getChannel();
		ByteBuffer buffer=ByteBuffer.allocate(1024);//allocate buffer
		
		byte[] message = { 'H', 'o', 'w', 'd', 'y', '!' };
		
		for(int i=0;i<message.length;i++){
			buffer.put(message[i]);
		}

//		System.out.println(fos);
		
		
		
		buffer.flip();
		fc.write(buffer);
		fc.close();
		fos.close();
	}
}
